import request from "./request";

/**
 * 获取博客列表数据
 * @returns 
 */
export async function getBlogs(page = 1, limit = 10, categoryid = -1) {
    return await request.get('/api/blog', {
        params: {
            page,
            limit,
            categoryid
        }
    });
}

/**
 * 获取博客分类
 */
export async function getBlogCategoryies() {
    return await request.get('/api/blogtype');
}

/**
 * 获取博客,文章详情页
 * @param {number} id 
 * @returns 
 */
export async function getBlog(id) {
    return await request.get(`/api/blog/${id}`)
}

/**
 * 提交评论
 * @param {commentInfo} 一个对象，里面包含：nickname  content   blogId
 */
export async function postComment(commentInfo) {
    return await request.post(`/api/comment`, commentInfo);
}

// 获取评论
// 传入id、页码、数据量
export async function getComments(blogid, page = 1, limit = 10) {
    return await request.get(`/api/comment`, {
        params: {
            blogid,
            page,
            limit
        }
    })
}
